package com.xyht.sca_s.student_manage_system.modules.videophone.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.modules.videophone.entity.req.SmsVideoPhoneLogAddReq;
import com.xyht.sca_s.student_manage_system.modules.videophone.service.SmsVideoPhoneLogService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 话机记录表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-08-16
 */
@RestController
@RequestMapping("/videophone")
public class SmsVideoPhoneLogController {

    @Autowired
    private SmsVideoPhoneLogService smsVideoPhoneLogService;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @ApiModelProperty("推送在线话单存通话记录")
    @PostMapping("/billing")
    public ResponseResult addVideoPhoneLog(@RequestBody SmsVideoPhoneLogAddReq addReq){
        return smsVideoPhoneLogService.addVideoPhoneLog(addReq);
    }

    @ApiModelProperty("查询学生信息（条件可以通过名字、学号、组织查询）")
    @GetMapping("/selectInfo")
    public ResponseResult selectInfo(@RequestParam(value = "student_name",required = false) String student_name,
                                     @RequestParam(value = "student_pin",required = false) String student_pin,
                                     @RequestParam(value = "org_id",required = false) String org_id,
                                     @RequestParam(value = "pageSize") Integer pageSize,
                                     @RequestParam(value = "pageNum") Integer pageNum){
        return smsVideoPhoneLogService.selectInfo(student_name,student_pin,org_id,pageSize,pageNum);
    }

    @ApiModelProperty("学生查询自己的信息")
    @GetMapping("/selectOwn")
    public ResponseResult selectOwn(
                                    HttpServletRequest request,
                                    @RequestParam(value = "pageSize") Integer pageSize,
                                    @RequestParam(value = "pageNum") Integer pageNum){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsVideoPhoneLogService.selectOwn(user_id,pageSize,pageNum);
    }
}

